package com.hex.ds.hdrs.log.service;

import com.hex.bigdata.hbda.base.Page;
import com.hex.ds.hdrs.common.utils.BaseUtil;
import com.hex.ds.hdrs.common.utils.MapUtil;
import com.hex.ds.hdrs.log.dao.ServerInteractLogDao;
import com.hex.ds.hdrs.log.po.ServerInteractLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务器交互日志表 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2020-11-26
 */
@Slf4j
@Service
public class ServerInteractLogService {

    @Autowired
    public ServerInteractLogDao serverInteractLogDao;

    /**
     * 查询 服务器交互日志
     *
     * @param serverInteractLog
     * @param page
     * @return
     */
    public List<ServerInteractLog> queryServerLog(ServerInteractLog serverInteractLog, Page page) {
        log.info("查询 服务器交互日志【ServerInteractLogService.queryServerLog】========");
        Map map = MapUtil.convertObjToMap(serverInteractLog);
        return serverInteractLogDao.queryServerLog(map, page);
    }

    /**
     * 新增日志
     *
     * @param serverInteractLog
     */
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void addLog(ServerInteractLog serverInteractLog) {
        serverInteractLog.setPkId(BaseUtil.getPkId());
        this.serverInteractLogDao.insert(serverInteractLog);
    }

    /**
     * @Method: reductionServerLog <br>
     * @Param: [bitchId] <br>
     * @Return: void <br>
     * @Description：还原服务器交互日志数据<br>
     * @Author： gc.zuo<br>
     * @Date： 2021/6/10 15:19 <br>
     * @Version： V1.0<br>
     */
    public void reductionServerLog(String bitchId) {
        this.serverInteractLogDao.reductionServerLog(bitchId);
    }

    public void delTaskByDate(Map map) {
        this.serverInteractLogDao.delTaskByDate(map);
    }
}
